package com.rice.riceaiagent.rag;

import jakarta.annotation.Resource;
import org.springframework.ai.document.Document;
import org.springframework.ai.embedding.EmbeddingModel;
import org.springframework.ai.vectorstore.SimpleVectorStore;
import org.springframework.ai.vectorstore.VectorStore;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.List;

/**
 * 简历辅导应用向量存储配置类
 * @author ricejson
 */
@Configuration
public class ResumeAppVectorStoreConfig {
    @Resource
    private MyMarkdownReader reader;
    @Bean
    public VectorStore resumeAppVectorStore(EmbeddingModel dashscopeEmbeddingModel) {
        // 创建SimpleVectorStore
        SimpleVectorStore vectorStore = SimpleVectorStore.builder(dashscopeEmbeddingModel)
                .build();
        // 加载文档
        List<Document> documents = reader.loadMarkdowns();
        vectorStore.add(documents);
        return vectorStore;
    }
}
